﻿Imports Logistica.Data
Imports Logistica.Entities

Public NotInheritable Class Almacen

    Public Shared Function Listar() As List(Of AlmacenBE)
        Dim listado As New List(Of AlmacenBE)
        Dim componenteDatos As New AlmacenDO


        Try
            listado = componenteDatos.Listar

        Catch ex As Exception
            Throw ex
        Finally
            componenteDatos = Nothing

        End Try

        Return listado
    End Function

    Public Shared Function Registrar(infoAlmancen As AlmacenBE) As Integer
        Dim idRegistro As Integer = 0
        Dim componenteDatos As New AlmacenDO

        Try
            If componenteDatos.Obtener(infoAlmancen).IsEmpty Then
                idRegistro = componenteDatos.Insertar(infoAlmancen)
            Else

                idRegistro = infoAlmancen.Id
                componenteDatos.Actualizar(infoAlmancen)
            End If

        Catch ex As Exception
            Throw ex

        Finally
            componenteDatos = Nothing
        End Try

        Return idRegistro
    End Function

    Public Shared Sub Eliminar(infoAlmacen)
        Dim componenteDatos As New AlmacenDO

        Try
            componenteDatos.Eliminar(infoAlmacen)

        Catch ex As Exception
            Throw ex

        Finally
            componenteDatos = Nothing
        End Try

    End Sub

    Shared Function Obtener(infoAlmacen As AlmacenBE) As AlmacenBE
        Dim componenteDatos As New AlmacenDO
        Dim almacenRegistrado As New AlmacenBE

        Try
            almacenRegistrado = componenteDatos.Obtener(infoAlmacen)

        Catch ex As Exception
            Throw ex
        Finally
            componenteDatos = Nothing

        End Try

        Return almacenRegistrado
    End Function

End Class
